package com.colorful.insuranceproject.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.colorful.insuranceproject.R;
import com.colorful.insuranceproject.bean.TransactionRecordBean;
import com.lovely3x.common.adapter.BaseViewHolder;
import com.lovely3x.common.adapter.ListAdapter;

import java.util.List;

import butterknife.Bind;

/**
 * Created by handsome-Bob on 2017/8/18.
 * <p>
 * 交易记录的适配器
 */
public class TransactionRecordAdapter extends ListAdapter<TransactionRecordBean> {

    public TransactionRecordAdapter(List<TransactionRecordBean> datas, Context context) {
        super(datas, context);
    }

    @NonNull
    @Override
    public BaseViewHolder createViewHolder(int position, ViewGroup parent) {
        return new ViewHolder(getLayoutInflater().inflate(R.layout.item_transaction_record, parent, false));
    }

    @Override
    public void handleData(int position, @NonNull BaseViewHolder holder) {
        ViewHolder viewHolder = (ViewHolder) holder;
        TransactionRecordBean bean = datas.get(position);

        viewHolder.tvOrderNum.setText(bean.getInsuranceNo());//  流水号
        viewHolder.tvForm.setText(bean.getInsuranceSrc());//  来源
        viewHolder.tvClaimsMoney.setText(bean.getRealInsuranceMoney());//  实际赔付金额
        viewHolder.tvClaimsTime.setText(bean.getInsuranceTime());//  理赔时间
    }

    class ViewHolder extends BaseViewHolder {

        @Bind(R.id.tv_order_num)
        TextView tvOrderNum;

        @Bind(R.id.tv_claims_money)
        TextView tvClaimsMoney;

        @Bind(R.id.tv_form)
        TextView tvForm;

        @Bind(R.id.tv_claims_time)
        TextView tvClaimsTime;

        public ViewHolder(View rootView) {
            super(rootView);
        }
    }

}
